<!-- author: wjc -->
<!-- date: 2022-03-11 16:38:53 -->
<!-- description:  -->
<template>
    <vBreadcrumbVue></vBreadcrumbVue>
    <div>
        <a-page-header title="Dashboard" style="background-color: #fff;" sub-title="Welcome !" />
        <a-row class="mt20">
            <a-col :span="6">
                <a-statistic
                    title="Active Users"
                    :value="112893"
                    class="bgff_pd16 bg1890ff"
                    valueStyle="color:#fff"
                    style="margin-right: 50px"
                />
            </a-col>
            <a-col :span="6">
                <a-statistic
                    title="Active Users"
                    :value="112893"
                    class="bgff_pd16 bg1890ff"
                    valueStyle="color:#fff"
                    style="margin-right: 50px"
                />
            </a-col>
            <a-col :span="6">
                <a-statistic
                    title="Active Users"
                    :value="112893"
                    class="bgff_pd16 bgeb2f96"
                    valueStyle="color:#fff"
                    style="margin-right: 50px"
                />
            </a-col>
            <a-col :span="6">
                <a-statistic
                    title="Active Users"
                    :value="112893"
                    class="bgff_pd16 bgeb2f96"
                    valueStyle="color:#fff"
                />
            </a-col>
        </a-row>
        <a-row class="mt20">
            <a-col class="pdr8" :span="12">
                <div class="bgff_pd16" style="width: 100%;">
                    <div id="echart_one"  style="width: 100%;"></div>
                </div>
            </a-col> 
            <a-col class="pdl8" :span="12">
                <div class="bgff_pd16" style="width: 100%;">
                    <div id="echart_tow"  style="width: 100%;"></div>
                </div>
            </a-col>
        </a-row>
       
    </div>
</template>

<script lang="ts" setup>
import { onMounted,onUpdated } from 'vue';
import { useRouter } from 'vue-router'
import * as echarts from 'echarts'

const router = useRouter()


onMounted(() => {
    //图表挂载 延迟加载一会 为获取正常的节点宽度
    setTimeout(creatEchart)
})
const creatEchart = () => {
    const creat_one = () => {
        let myChart = echarts.init(document.getElementById('echart_one') as HTMLElement);
        const option = {
            xAxis: {
                type: 'category',
                data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
            },
            yAxis: {
                type: 'value'
            },
            series: [
                {
                    data: [150, 230, 224, 218, 135, 147, 260],
                    type: 'line'
                }
            ]
        };
        // 绘制图表
        myChart.setOption(option);
    }
    const creat_tow = () => {
        let myChart = echarts.init(document.getElementById('echart_tow') as HTMLElement);
        const option = {
            title: {
                text: 'Stacked Line'
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine']
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            toolbox: {
                feature: {
                    saveAsImage: {}
                }
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
            },
            yAxis: {
                type: 'value'
            },
            series: [
                {
                    name: 'Email',
                    type: 'line',
                    stack: 'Total',
                    data: [120, 132, 101, 134, 90, 230, 210]
                },
                {
                    name: 'Union Ads',
                    type: 'line',
                    stack: 'Total',
                    data: [220, 182, 191, 234, 290, 330, 310]
                },
                {
                    name: 'Video Ads',
                    type: 'line',
                    stack: 'Total',
                    data: [150, 232, 201, 154, 190, 330, 410]
                },
                {
                    name: 'Direct',
                    type: 'line',
                    stack: 'Total',
                    data: [320, 332, 301, 334, 390, 330, 320]
                },
                {
                    name: 'Search Engine',
                    type: 'line',
                    stack: 'Total',
                    data: [820, 932, 901, 934, 1290, 1330, 1320]
                }
            ]
        };
        // 绘制图表
        myChart.setOption(option);
    }
    creat_one()
    creat_tow()
}


</script>

<style scoped lang='less'>
:deep(.ant-statistic-title) {
    color: #fff;
}
#echart_one {
    height: 275px;
    width: 100%;
    overflow: hidden;
}
#echart_tow {
    height: 275px;
    width: 100%;
    overflow: hidden;
}
</style>